package com.study.service.impl;

import com.study.mapper.AccountAmountMapper;
import com.study.service.AccountAmountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 账户金额
 *
 * Created by 西街恶人 on 2021/5/23.
 */
@Service
public class AccountAmountServiceImpl implements AccountAmountService {

    @Autowired
    private AccountAmountMapper accountAmountMapper;

    /**
     * 转账
     * @param fromUserAccountId 从谁那儿转账
     * @param toUserAccountId 转到谁那儿去
     * @param amount 转账金额
     */
    @Override
    public void transfer(Long fromUserAccountId, Long toUserAccountId, Double amount) {
        accountAmountMapper.updateAmount(fromUserAccountId, -amount);
        accountAmountMapper.updateAmount(toUserAccountId, amount);
    }
}
